﻿using System;
using Autodesk.Revit.DB;
using YJKCopyModel.QuickModelFrame;

namespace YJKCopyModel.InteractiveOperation.CmdTestInteractiveOperation
{
	[Rebuilder(RebuilderName = "TestCurve")]
	internal class TestCurveRebuilder : IRevitModelRebuilder
	{
		public bool TryRebuildRevitModel(Autodesk.Revit.DB.Document inputDoc, RevitModelRequest inputReqeust, out BuildData buildData)
		{
			buildData = new BuildData();
			Transaction transaction = new Transaction(inputDoc, "创建模型线");
			try
			{
				transaction.Start();
				TestCurveRevitModelRequest testCurveRevitModelRequest = inputReqeust as TestCurveRevitModelRequest;
				foreach (CurveCadElement curveCadElement in testCurveRevitModelRequest.RequestData.LstCurveElements)
				{
					TestCommon.CreateModelCurve(curveCadElement.ThisCurve, inputDoc, new Autodesk.Revit.DB.Color(0, byte.MaxValue, 0), 1);
				}
				transaction.Commit();
			}
			catch (Exception)
			{
				bool flag = transaction.HasStarted();
				if (flag)
				{
					transaction.RollBack();
				}
			}
			return true;
		}
	}
}
